#pragma once

#include <gofcl_dac_r.h>

typedef enum {
	DAC0_DH_R = 0x8,
	DAC1_DH_R = 0x14,
	DACC_DH_R = 0x20,
} dac_dh_re;

typedef enum {
	DAC_DH_R12DH_RR = 0x0,
	DAC_DH_L12DH_RR = 0x4,
	DAC_DH_R8DH_RR = 0x8,
} dac_dh_rre;

// 获取给定DAC的给定DH寄存器的地址
static inline u32_s dac_dh_get_reg_q(dac_dh_re dac_dh_r, dac_dh_rre dac_dh_rr) {
	return DAC_Q + dac_dh_r + dac_dh_rr;
}

static inline void dac_wreg_dh(dac_dh_re dac_dh_r, dac_dh_rre dac_dh_rr,
			       u32_s value) {
	u32_s reg_q = dac_dh_get_reg_q(dac_dh_r, dac_dh_rr);
	wreg(reg_q, value);
}

static inline u32_s dac_rreg_dh(dac_dh_re dac_dh_r, dac_dh_rre dac_dh_rr) {
	u32_s reg_q = dac_dh_get_reg_q(dac_dh_r, dac_dh_rr);
	return rreg(reg_q);
}
